package com.cruel_wandering.wifi_geo_predictor;

import java.util.List;

import com.cruel_wandering.wifi_geo_predictor.wifi_simulation.MyScanResult;
import com.cruel_wandering.wifi_geo_predictor.wifi_simulation.MyWifiManager;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;

public class WifiScaner extends BroadcastReceiver {

	private MyWifiManager wifi;

  public WifiScaner(MyWifiManager wifiSource) {
    super();
    wifi = wifiSource;
  }

  @Override
  public void onReceive(Context c, Intent intent) {
    List<MyScanResult> results = wifi.getScanResults();
    MyScanResult bestSignal = null;
    for (MyScanResult result : results) {
      if (bestSignal == null
          || WifiManager.compareSignalLevel(bestSignal.level, result.level) < 0)
        bestSignal = result;
    }
  }

}
